Conversation
Prepend a URL scheme to bare IP:port endpoints so the OTel SDK can parse them. Use WithEndpointURL consistently for all exporters and update the env var so the SDK reads a valid URL internally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Issue: LFXV2-608 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
WithEndpointURL receives the normalized endpoint explicitly, making the env var mutation unnecessary. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Issue: LFXV2-608 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
WalkthroughAdded Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
There was a problem hiding this comment.
Pull request overview
This pull request improves OpenTelemetry endpoint handling by adding URL normalization to support bare IP:port values and migrating from deprecated SDK methods. The changes ensure compatibility with the OTel SDK v1.40.0's URL parsing requirements, which fail on bare IP:port endpoints without schemes.
Changes:
- Added
endpointURLhelper function to normalize endpoints by prepending appropriate HTTP/HTTPS schemes based on theInsecureflag - Migrated all OTLP exporter configurations from deprecated
WithEndpointtoWithEndpointURLmethods across traces, metrics, and logs exporters - Added comprehensive unit tests for URL normalization and integration test for bare IP:port endpoint handling
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/utils/otel.go | Added endpointURL helper function and updated all OTLP exporters to use WithEndpointURL instead of deprecated WithEndpoint |
| pkg/utils/otel_test.go | Added unit tests for endpointURL function and integration test for bare IP:port endpoint configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| import ( | ||
| "context" | ||
|
|
There was a problem hiding this comment.
Remove the blank line between standard library imports. Both "context" and "testing" are standard library packages and should be grouped together without a blank line separator. Go convention typically uses blank lines only to separate standard library imports from third-party imports.
This pull request improves the handling of OpenTelemetry (OTel) endpoint URLs to ensure compatibility with the OTel SDK's expectations and to prevent errors when using bare IP:port endpoints. The main enhancement is the normalization of the endpoint configuration to always include a URL scheme, which is now required for correct parsing by the SDK. The changes also update the SDK option usage to expect full URLs and add comprehensive tests for the new logic.
Endpoint normalization and SDK compatibility:
endpointURLhelper function inotel.goto ensure that the OTel endpoint always includes a URL scheme (http://orhttps://), preventing SDK parsing errors with bare IP:port values. The function prepends the appropriate scheme based on theInsecureflag and leaves existing URLs unchanged. (pkg/utils/otel.go, [1] [2]WithEndpointURLmethods instead of the deprecatedWithEndpoint, ensuring the endpoint is always parsed as a URL and aligning with the latest SDK requirements. (pkg/utils/otel.go, [1] [2] [3] [4] [5] [6]Testing improvements:
endpointURLfunction to verify correct scheme prepending and preservation of existing schemes. (pkg/utils/otel_test.go, pkg/utils/otel_test.goR427-R521)SetupOTelSDKWithConfigcorrectly normalizes a bare IP:port endpoint, preventing SDK errors related to invalid URL parsing. (pkg/utils/otel_test.go, pkg/utils/otel_test.goR427-R521)